module lang.languagefactory;

import utils.log;
import std.string: format;

import lang.language;
import lang.d.dlanguage;
import vfs.documenttype;

class LanguageFactory {
    private static shared Language[DocumentType] myLanguageMap;

    static this() {
        myLanguageMap[DocumentType.D_FILE] = DLanguage.getInstance();
    }

    private this() {
    }

    public static shared(Language) getLanguage(in DocumentType documentType) {
        return (documentType in myLanguageMap) ? myLanguageMap[documentType] : null;
    }
}

unittest {
    assert(LanguageFactory.getLanguage(DocumentType.D_FILE).classinfo.name == "lang.d.dlanguage.DLanguage");
    assert(LanguageFactory.getLanguage(DocumentType.XML_FILE) is null);
}
